//
//  PKResultImageListViewController.swift
//  GoAbroad
//
//  Created by Pink Snow on 2025/5/21.
//

import UIKit
import VerticalCardSwiper
import SnapKit

class PKResultImageListViewController: PKBaseViewController ,VerticalCardSwiperDatasource ,NavigationBarConfigurable {

    

    var cardSwiper : VerticalCardSwiper!
        var showBackButton: Bool {  false }
        var shouldHideNavigationBar: Bool { true }
    let backButton = UIButton(type: .custom)
    let titleLabel = UILabel()
    override func setupUI() {
        setupNavigationBar()
        view.backgroundColor = .white
//        title = "Result Tattoo Image"
        backButton.setImage(.init(named: "back"), for: .normal)
        view.addSubview(backButton)
        backButton.snp.makeConstraints { make in
            make.left.equalTo(ScreenAdapter.x(20))
            make.top.equalTo(DeviceHelper.navigationBarHeight + 20)
            make.width.height.equalTo(ScreenAdapter.x(30))
        }
        backButton.rx.tap.subscribe { _ in
            self.navigationController?.popViewController(animated: true)
        }.disposed(by: rx.disposeBag)
        titleLabel.text = "Result  Tattoo List"
        titleLabel.font = .adaptedBoldFont(size: 18)
        view.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(DeviceHelper.navigationBarHeight+20)
        }
        cardSwiper = VerticalCardSwiper()
        cardSwiper.isSideSwipingEnabled = false
        view.addSubview(cardSwiper)
        cardSwiper.delegate = self
        cardSwiper.datasource = self
        cardSwiper.snp.makeConstraints { make in
            make.top.equalTo(DeviceHelper.navigationFullHeight + 10)
            make.left.right.equalToSuperview()
            make.bottom.equalTo(-DeviceHelper.bottomSafeAreaHeight - 20 )
        }
        
        cardSwiper.register(nib: UINib(nibName: "ResultCell", bundle: nil), forCellWithReuseIdentifier: "ResultCell")
    }
    
    override func bindEvents() {
        
    }
    
    override func bindViewModel() {
        
    }
    
    func numberOfCards(verticalCardSwiperView: VerticalCardSwiperView) -> Int {
        return 2
    }
    
    func cardForItemAt(verticalCardSwiperView: VerticalCardSwiperView, cardForItemAt index: Int) -> CardCell {
        if let cardCell = verticalCardSwiperView.dequeueReusableCell(withReuseIdentifier: "ResultCell", for: index) as? ResultCell {
            
            let color = UIColor.red
            cardCell.backgroundColor = color
            
            return cardCell
        }
        
        
        
        return CardCell()
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}

extension PKResultImageListViewController : VerticalCardSwiperDelegate {
    
    func didScroll(verticalCardSwiperView: VerticalCardSwiperView) {
        
        
    }
    
//    
//    func sizeForItem(verticalCardSwiperView: VerticalCardSwiperView, index: Int) -> CGSize {
//        
//        return .init(width: ScreenAdapter.baseWidth-40, height: ScreenAdapter.baseWidth * 1280 / 720)
//        
//        
//    }
    
}


